/*Bubble Sort Algorithm*/
#include<stdio.h>
#include<string.h>
#include<time.h>
#define ARRAYSIZE 	6	
#define TRUE 		1
#define FALSE		0


void print_array(int a[])
{
	int i;
       	for(i=0;i<ARRAYSIZE;i++){
	       printf("- %d -", a[i]);
	}
	printf("\n");
}

int main() 
{
	int a[ARRAYSIZE];
	int i,j,t,posicion,number,steps=0,found, cont=TRUE;
	srand(time(0));
	for(i=0;i<ARRAYSIZE;i++){
		a[i] = random() % 100;
	}
	print_array(a);
	printf("Enter the number you want to look for:\n");
	scanf("%d", &number);
	for(j=0;cont&&j<ARRAYSIZE-1;j++){ 	//Here we don't go as far
		cont = FALSE;			//as the last element
		for(i=0;i<ARRAYSIZE-j-1;i++){	
			steps++;
			if(a[i]>a[i+1]){	//Max value of expression
				t = a[i];	//is (n-2)>(n-1)
				a[i] = a[i+1];
				a[i+1] = t;
				cont = TRUE;
			}
		}
	}

	for(i=0;found==0&&i<ARRAYSIZE;i++){
		if(a[i]==number){
			found = 1;
		}
	}
	if (found == 1){
		printf("The number %d is at the %d array element\n", number,i);
	} else {
		printf("The number %d was not found in the array\n",number);
	}

	return 1;	
}		
